﻿using System.IO;
using XSerialization.Generator;

namespace XCodeGenerator
{
    /// <summary>
    /// Xsd File Interface
    /// </summary>
    public interface IXsdFile
    {
        /// <summary>
        /// Name of the xsd file.
        /// </summary>
        string Name { get; set; }

        /// <summary>
        /// Full path of the xsd file.
        /// </summary>
        string Path { get; set; }

        /// <summary>
        /// Meta informations about the code file.
        /// </summary>
        IFileMetaInfo CodeMetaInfo { get; set; }

        /// <summary>
        /// Meta informations about the interface file.
        /// </summary>
        IFileMetaInfo InterfaceMetaInfo { get; set; }
    }

    /// <summary>
    /// Xsd File Class
    /// </summary>
    public class XsdFile : IXsdFile
    {
        /// <summary>
        /// Name of the xsd file.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Full path of the xsd file.
        /// </summary>
        public string Path { get; set; }

        /// <summary>
        /// Meta informations about the code file.
        /// </summary>
        public IFileMetaInfo CodeMetaInfo { get; set; }

        /// <summary>
        /// Meta informations about the interface file.
        /// </summary>
        public IFileMetaInfo InterfaceMetaInfo { get; set; }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="file"></param>
        /// <param name="defaultDir"></param>
        /// <param name="nameSpace"></param>
        public XsdFile(FileInfo file, string defaultDir, string nameSpace)
        {
            Name = file.Name;
            Path = file.FullName;
            string internalName = Name.Replace(".xsd", "") + ".cs";

            CodeMetaInfo = new FileMetaInfo(internalName, defaultDir, nameSpace, "");
            InterfaceMetaInfo = new FileMetaInfo("I" + internalName, defaultDir, nameSpace, "");
        }
    }
}
